<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="工器具编码" prop="materialCode">
        <el-input v-model="queryParams.materialCode" placeholder="请输入工器具编码" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="工器具名称" prop="materialName">
        <el-input v-model="queryParams.materialName" placeholder="请输入工器具名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="归还日期" prop="inDate">
        <el-date-picker clearable v-model="queryParams.inDate" type="date" value-format="yyyy-MM-dd" placeholder="请选择归还日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['elec:elecMaterialInDetail:export']">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <el-table v-loading="loading" :data="elecMaterialInDetailList">
      <el-table-column label="工器具ID" align="center" prop="indetailId" />
      <el-table-column label="工器具编码" align="center" prop="materialCode" width="100" />
      <el-table-column label="工器具名称" align="center" prop="materialName" width="200" />
      <el-table-column label="归还人" align="center" prop="createBy" width="100" />
      <el-table-column label="归还时间" align="center" prop="inDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.inDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="分类" align="center" prop="sortName" width="100" />
      <el-table-column label="库房" align="center" prop="warehouseName" width="100" />
      <el-table-column label="柜架" align="center" prop="cabinetName" width="100" />
      <el-table-column label="层位" align="center" prop="gridName" width="100" />
      <el-table-column label="供应商" align="center" prop="providerName" width="100" />
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
  </div>
</template>

<script>
  import {
    listElecMaterialInDetail,
  } from "@/api/elec/elecMaterialInDetail";

  export default {
    name: "ElecMaterialInDetail",
    dicts: ['in_status', 'batch_type', 'is_in'],
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 物资入库详情表格数据
        elecMaterialInDetailList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          inId: null,
          materialId: null,
          inWeight: null,
          isIn: null,
          inDate: null,
          materialCode: null,
          materialName: null
        },
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询物资入库详情列表 */
      getList() {
        this.loading = true;
        listElecMaterialInDetail(this.queryParams).then(response => {
          this.elecMaterialInDetailList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download('elec/elecMaterialInDetail/export', {
          ...this.queryParams
        }, `elecMaterialInDetail_${new Date().getTime()}.xlsx`)
      }
    }
  };
</script>
